package pruebas.inputMask;

import general.TestCore;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.Test;

import constants.ConfigurationConstants;
import constants.DataProviderConstants;
import dataprovider.DataProviderArguments;

public class InputMask1 extends TestCore{

	@Test(dataProviderClass = dataprovider.DataProviderFactory.class, dataProvider = ConfigurationConstants.DP_FACTORY)
	@DataProviderArguments(ConfigurationConstants.ESCENARIO
			 + ConfigurationConstants.EQUALS
			 + DataProviderConstants.HOJA_11)
	public void testInputMaskProductKey(String param1, String param2, String param3) {
		
		
		selenium.open("/showcase/");
		driver.manage().window().maximize();
		
		WebElement boton = driver.findElement(By.id("SubMenu-Input"));
		boton.click();
		selenium.waitForPageToLoad("30000");

		WebElement boton1 = driver.findElement(By.xpath("//*[@id='MENUSIDEindent']/div[3]/a[10]"));
		boton1.click();
		selenium.waitForPageToLoad("30000");
		
		WebElement boton2 = driver.findElement(By.id("j_idt88:key"));
		boton2.click();
		selenium.waitForPageToLoad("1000");
		WebElement webElement=null;
		webElement.sendKeys(param1);
		webElement.sendKeys(param2);
		webElement.sendKeys(param3);
		
		webElement = driver.findElement(By.id("j_idt88:j_idt97"));
		webElement.click();
		selenium.waitForPageToLoad("30000");

		WebDriverWait webDriverWait = new WebDriverWait(driver, 3);
		webDriverWait.until(ExpectedConditions.elementToBeClickable(
				By.xpath("//*[@id='j_idt88:display']/tbody/tr[6]/td[2]")));;
		
		//se valida la seleccion exitosas8
		if(selenium.isElementPresent("//*[@id='j_idt88:display']/tbody/tr[6]/td[2]")){
			webElement = driver.findElement(By.xpath("//*[@id='j_idt88:display']/tbody/tr[6]/td[2]"));
		}else{
			webElement = null;
		}

		Assert.assertNotNull(webElement);
	}

}
